
<template>
    <div>
        <el-table :data="itemlist" :header-cell-style="{background:'#f6f9fe',color:'#7690db'}">
            <el-table-column align="center" prop="listCode"  label="集合编号" ></el-table-column>
            <el-table-column align="center" prop="icdCode"  label="ICD名称" ></el-table-column>
            <el-table-column align="center" prop="icdName"  label="ICD编码" ></el-table-column>
            <el-table-column align="center" prop="createTime"  label="创建时间" ></el-table-column>
            <el-table-column align="center" fixed="right"  label="操作">
                <template slot-scope="scope">
                    <el-button type="text"  class="edit" @click="handledit(scope.row)">编辑</el-button>
                    <el-divider direction="vertical"></el-divider>
                    <el-button type="text" class="del" @click="handldel(scope.row)">删除</el-button>
                </template>
            </el-table-column>
        </el-table>
        <Pagination style="text-align: center;" :total="total" :page.sync="listQuery.page" @pagination="getexcludepage" :limit.sync="listQuery.num"></Pagination>
        <el-dialog :title="title" :visible.sync="aisvisible" width="40%" :close-on-click-modal="false">
            <el-form ref="addForm" :model="addForm"  label-width="90px">
                <el-form-item label="集合编号" prop="listCode">
                    <el-input v-model="addForm.listCode"></el-input>
                </el-form-item>
                <el-form-item   el-form-item label="ICD编码" prop="icdCode">
                    <el-input v-model="addForm.icdCode"></el-input>
                </el-form-item>
                <el-form-item   el-form-item label="ICD名称" prop="icdName">
                    <el-input v-model="addForm.icdName"></el-input>
                </el-form-item>
                <el-form-item label="动作" prop="action">
                    <el-input v-model="addForm.action"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="handleonSubmit" class="btncolor" size="small" :loading="loading" :disabled="loading">确定</el-button>
                    <el-button @click="aisvisible = false" size="small">取消</el-button>
                </el-form-item>
            </el-form>
        </el-dialog>
    </div>
    
</template>
<script>
import Pagination from "@/components/Pagination";
import {
    Dexcludepage,Dexcludeadd,Dexcludeinfo,Dexcludedel,Dexcludeupdate
} from '@/api/version.js'

export default {
    components: { Pagination },
    data() {
        return{
            aisvisible:false,
            title:'创建exclude',
            addForm:{
                branchId:this.$route.query.branchId,
                projectId:this.$route.query.projectId
            },
            loading:false,
            listQuery: {
                page: 1,
                num: 10,
                branchId:this.$route.query.branchId,
                projectId:this.$route.query.projectId,
            },
            total:0,
            itemlist:[],
        }
    },
    methods:{

        handleonSubmit(){
            if(this.title == '创建exclude'){
                this.Dexcludeaddhead()
            }else{
                this.Dexcludeedithand()
            }
        },
        // ---------------------------DRG的增删改查--------------------------------------------------/
        getexcludepage(){
            this.$getFlag().then(obj=>{
                Dexcludepage(this.listQuery,obj.data).then(res=>{
                    if(res.status == 200){
                        this.itemlist = res.list
                    }
                })
            })
        },
        // 增加drg
        Dexcludeaddhead(){
            this.addForm.branchId= this.$route.query.branchId,
            this.addForm.projectId=this.$route.query.projectId
            this.$getFlag().then(obj=>{
                Dexcludeadd(this.addForm,obj.data).then(res=>{
                    if(res.status == 200){
                        this.$notify({  title: "操作成功", message: res.msg, type: "success",duration: 2000,});
                        this.getexcludepage()
                    }else{
                        this.$notify({ title: "操作失败",message: res.msg, type: "error", duration: 2000,});
                    }
                    this.aisvisible = false
                })
            })
        },
         // 删除
        handldel(item){
            let data = {
                id:item.id,
                branchId:this.$route.query.branchId,
                projectId:this.$route.query.projectId,
            }
            this.$confirm('确定要删除吗？', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                type: 'warning'
            }).then(() => {
                this.$getFlag().then(obj=>{
                    Dexcludedel(data,obj.data).then(res=>{
                        if(res.status == 200){
                            this.$notify({  title: "操作成功", message: res.msg, type: "success",duration: 2000,});
                            this.getexcludepage()
                        }else{
                            this.$notify({ title: "操作失败",message: res.msg, type: "error", duration: 2000,});
                        }
                    })
                })
            })
            .catch(() => {});
        },
       
        // 详情
        Dexcludeinfohand(id,branchId,projectId){
            this.$getFlag().then(obj=>{
                Dexcludeinfo({id:id,branchId:branchId,projectId:projectId},obj.data).then(res=>{
                    if(res.status == 200){
                        this.addForm = res.data
                    }
                })
            })
        },
        // 总编辑
        handledit(item){
            this.aisvisible = true
            this.title = "编辑exclude"
            this.Dexcludeinfohand(item.id,this.$route.query.branchId,this.$route.query.projectId)
        },
        // 修改
        Dexcludeedithand(){
            this.addForm.branchId= this.$route.query.branchId,
            this.addForm.projectId=this.$route.query.projectId
            this.$getFlag().then(obj=>{
                Dexcludeupdate(this.addForm,obj.data).then(res=>{
                    if(res.status == 200){
                        this.$notify({  title: "操作成功", message: res.msg, type: "success",duration: 2000,});
                        this.getexcludepage()
                    }else{
                        this.$notify({ title: "操作失败",message: res.msg, type: "error", duration: 2000,});
                    }
                    this.aisvisible = false
                })
            })
        },
    }

}

</script>
<style scoped lang="scss">
::v-deep .el-table__body .cell{
    color: #868895;
}
</style>